package com.xhh.fs.utils;

import java.util.Random;

public class StringUtils {
    // 生产指定长度的随机字符串(做图片前缀)
    public static String getRandomString(int length){
        //随机字符串集
        String base = "abcdefghijklmnopqrstuvwxyz0123456789";
        Random random = new Random();
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < length; i++) {
            //取随机下标
            int number = random.nextInt(base.length());
            //插入随机字符sb
            sb.append(base.charAt(number));
        }
        return sb.toString();
    }
}
